<template>
	<view class="lgmain animated fadeIn faster">
		<view class="px-5 d-flex d-flex-middle" :style="{'paddingTop':$store.state.statusBarHeight+'px','height': $store.state.titleBarHeight + 'px'}" @click="goBack">
			<text class="icon-31fanhui1 iconfont"></text>
		</view>
		<view style="padding-top: 200rpx;">
			<view class="d-flex d-flex-column d-flex-center d-flex-middle">
				<image class="mb-5" src="https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/appUpload/20241223141109-ac38c1fa-47fb-46f8-83fc-1f37a1474265.png" style="width: 190rpx;height: 190rpx;"></image>
				<image class="mb-15" src="https://168809.oss-cn-hangzhou.aliyuncs.com/community/temp/goxiaoda.png" mode="widthFix" style="width: 222rpx;"></image>
				<view class="px-6 d-flex-center">
					<button v-if="isChecked" class="wxbutton d-flex d-flex-middle d-flex-center" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">手机号快捷登录</button>
					<button v-else class="wxbutton d-flex d-flex-middle d-flex-center" @click="wxlogin">手机号快捷登录</button>
					<view class="d-flex d-flex-top" style="margin-top: 20rpx;margin-bottom: 220rpx;">
						<checkbox :checked="isChecked" style="transform:scale(0.6)" @click="isChecked = !isChecked"></checkbox>
						<view>
							<text class="font24 color999" @click="isChecked = !isChecked">已阅读并同意</text>
							<text class="font24 colorlan" @click="privacy">《用户协议》</text>
							<text class="font24 color999">和</text>
							<text class="font24 colorlan" @click="privacy">《隐私条款》</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import store from '@/store/index.js';
	import { manner } from "@/util/manner.js";
	import { userApi } from '@/http/userApi.js';
	export default {
		data() {
			return {
				isChecked:false,
				telIv: '',
				encryptedData: '',
				code: '',
			}
		},
		onLoad() {
			let that = this
			uni.login({
				success: res => {
					that.code = res.code
					console.log('code',that.code)
				},
				fail: res => {
					console.log(res)
				}
			});
		},
		methods: {
			privacy(){
				uni.navigateTo({
					url:'/pagesMain/privacy/privacy'
					// url:'/pagesMain/hobby/hobby'
				})
			},
			async getPhoneNumber(e) {
				if (e.target.errMsg === 'getPhoneNumber:ok') {
					this.telIv = e.detail.iv;
					this.encryptedData = e.detail.encryptedData;
					//登录
					this.getLogin();
				} else {
					uni.showToast({
						icon: 'error',
						title: '用户拒绝获取'
					})
				}
			},
			async getLogin() {
				var me = this;  
				const from = {
					telIv: encodeURIComponent(me.telIv),
					telDatail: encodeURIComponent(me.encryptedData),
					code: encodeURIComponent(me.code)
				}
			},
			wxlogin(){
				let that =this
				if(!that.isChecked){
					return uni.showToast({
						title:'请先勾选用户协议',
						icon:'none',
					});
				}
			},
			
			fastLogin(){
				uni.login({
					provider:'univerify',
					univerifyStyle:{
						fullScreen:false,
						"backgroundImage": "https://168809.oss-cn-hangzhou.aliyuncs.com/community/temp/bootbg.png",
						"icon": {
						    "path": "static/images/logo.png",
						    "width":  "60px",
						    "height": "60px"
						},
						// "closeIcon": {
						//     "path": "static/images/31fanhui1.png",
						//     "width":  "60px",
						//     "height": "60px"
						// },
						"phoneNum": {
						    "color": "#202020"
						},
						"slogan": {
						    "color": "#BBBBBB"  //  slogan 字体颜色 默认值：#BBBBBB
						},
						"authButton": {
						    "normalColor": "#70dec1",
						    "highlightColor": "#03dda4",
						    "disabledColor": "#dce0df",
						    "textColor": "#ffffff",
						    "title": "本机号码一键登录",
						    "borderRadius": "24px"
						},
						"otherLoginButton": {
							"visible": false
						},
						"privacyTerms": {
						    "defaultCheckBoxState":true,
						    "isCenterHint":false,
						    "checkBoxSize":12,
							"checkedImage":"static/images/checkbox-checked.png",
							"uncheckedImage":"static/images/checkbox.png",
						    "textColor": "#BBBBBB",
						    "termsColor": "#43abe5",
						    "prefix": "我已阅读并同意",
						    "suffix": "并使用本机号码登录"
						},
					},
					success:res=>{
						console.log('res',res)
						setTimeout(()=>{
							uni.closeAuthView()
						},1000)
					},fail(err) {
						console.log('err',err)
					}
				})
			},
			alogin(){
				uni.navigateTo({
					url:'/pagesMain/mplogin/mplogin'
				})
			},
			goBack(){
				manner.goBack()
			}
		}
	}
</script>

<style scoped>
.lgmain{
	background-image: url('https://168809.oss-cn-hangzhou.aliyuncs.com/community/temp/bootbg.png');
	background-repeat: no-repeat;
	background-size: cover;
	background-position: 0 100%;
	min-height: 100vh;
	position: relative;
}
</style>
